﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace GiveAQuiz.Questions
{
  public partial class MultipleChoiceQuestionEditor : UserControl
  {
    public MultipleChoiceQuestionEditor()
    {
      InitializeComponent();
    }

    // Manually handle selection since our objects are across a data template
    // and GroupName is too global
    private void RadioButton_Checked(object sender, RoutedEventArgs e)
    {
      var type = DataContext as MultipleChoiceQuestionType;
      var button = (RadioButton)sender;
      var item = button.DataContext as MultipleChoiceQuestionItem;
      if (type != null && item != null)
      {
        foreach (var choice in type.Choices)
        {
          choice.IsCorrectChoice = (item == choice);
        }
      }
    }
  }
}
